package com.adtech.farmProducts.utils;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

/**
 * Time:2019/6/22
 * Created by xiaocz
 * Describe
 */
public class MoveToPostion {

    /**
     * 将position项移动到顶部
     * @param position item项
     */
    public  static  void moveToPosition(RecyclerView mRecyclerView, int position) {
        if (position != -1) {
            mRecyclerView.scrollToPosition(position);
            LinearLayoutManager mLayoutManager =
                    (LinearLayoutManager) mRecyclerView.getLayoutManager();
            mLayoutManager.scrollToPositionWithOffset(position, 0);
        }
    }
}
